//当前模块，API进行统一管理，即对请求接口统一管理
import requests from "@/api/request";
//mockde
import mockRequests from "./mockAjax";



//对外暴露函数
export default {
    // 用户认证相关接口
    reqUserLogin(data) {
        return requests({
            url: '/auth/login',
            method: 'post',
            data
        })
    },
    reqUserRegister(data) {
        return requests({
            url: '/auth/register', 
            method: 'post',
            data
        })
    },

    // 首页数据相关接口
    reqHomeData() {
        return requests({
            url: '/home',
            method: 'get'
        })
    },

    // 商品相关接口
    reqProductList(params) {
        return requests({
            url: '/products',
            method: 'get',
            params
        })
    },
    reqProductDetail(id) {
        return requests({
            url: `/products/${id}`,
            method: 'get'
        })
    },

    // 购物车相关接口 
    reqAddToCart(data) {
        return requests({
            url: '/cart',
            method: 'post',
            data
        })
    },

    // 订单相关接口
    reqCreateOrder(data) {
        return requests({
            url: '/orders',
            method: 'post',
            data
        })
    },
    reqOrderList(params) {
        return requests({
            url: '/orders',
            method: 'get',
            params
        })
    }
}



